<template>
  <component :is="type" :to="path">
    <slot />
  </component>
</template>

<script lang="ts">
import { computed, defineComponent, PropType } from 'vue'

export default defineComponent({
  props: {
    path: {
      type: String as PropType<string>,
      required: true
    }
  },
  setup(props) {
    const type = computed(() =>
      props.path.match(/^https?:\/\//) ? 'a' : 'router-link'
    )

    return { type }
  }
})
</script>